package com.hq.ims.platform.controller;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.entity.*;
import com.hq.ims.data.entityenum.EnumDataType;
import com.hq.ims.data.service.BaseCompanyService;
import com.hq.ims.data.utils.LocalConstant;
import com.hq.ims.data.utils.WebExpandUtils;
import com.hq.ims.data.vo.*;
import com.hq.mybatis.base.page.RequestPage;
import com.hq.mybatis.base.page.ReturnPage;
import com.hq.utils.vo.ReturnVo;
import com.hq.web.annotations.GetJsonValue;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "平台企业信息")
@RestController
@RequestMapping(LocalConstant.SYS_TYPE_PLATFORM_URL_PREFIX + "/company")
public class PlatformCompanyController {

    @Resource
    private BaseCompanyService baseCompanyService;

    @ApiOperation(value = "查询企业信息", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getCompanyPage", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo getCompanyPage(@RequestBody RequestPage page, @RequestBody CompanyMapstruct.PageSearchVo searchVo) {
        ReturnPage companyReturnVo = baseCompanyService.getCompanyPage(page, searchVo);
        return ReturnVo.buildSuccess(companyReturnVo);
    }

    @ApiOperation(value = "查询企业信息下拉", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getCompanyList", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo getCompanyList(@RequestBody CompanyMapstruct.PageSearchVo searchVo) {
        List<Company> companyList = baseCompanyService.getCompanyList(searchVo);
        return ReturnVo.buildSuccess(companyList);
    }

    @ApiOperation(value = "查询企业详情", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getCompanyDetail", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo getCompanyDetail(@RequestBody Company company) {
        CompanyMapstruct.CompanyVo companyVos = baseCompanyService.getCompanyDetail(company);
        return ReturnVo.buildSuccess(companyVos);
    }

    @ApiOperation(value = "企业修改", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/updCompanyInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo updCompanyInfo(@RequestBody CompanyMapstruct.CompanyVo companyVo) {
        boolean b = baseCompanyService.updCompanyInfo(companyVo);
        return ReturnVo.buildSuccess(b);
    }

    @ApiOperation(value = "企业审核列表", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/checkCompanyPage", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo checkCompanyPage(@RequestBody RequestPage page, @RequestBody CompanyMapstruct.PageSearchVo searchVo) {
        ReturnPage companyReturnVo = baseCompanyService.checkCompanyPage(page, searchVo);
        return ReturnVo.buildSuccess(companyReturnVo);
    }

    @ApiOperation(value = "查看企业审核详情", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/checkCompanyDetail", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo checkCompanyDetail(@RequestBody CompanyCheck check) {
        CompanyCheckMapstruct.CompanyCheckVo companyCheckVo = baseCompanyService.checkCompanyDetail(check);
        return ReturnVo.buildSuccess(companyCheckVo);
    }

    @ApiOperation(value = "企业审核", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/checkCompanyInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo checkCompanyInfo(@RequestBody List<CompanyCheckMapstruct.CompanyCheckVo> checks) {
        boolean b = baseCompanyService.checkCompanyInfo(checks);
        return ReturnVo.buildSuccess(b);
    }

    @ApiOperation(value = "查看审核历史", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getCompanyChangeHistory", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo getCompanyChangeHistory(@RequestBody RequestPage page, @RequestBody CompanyChangeHistoryMapstruct.CompanyChangeHistoryVo companyChangeHistory) {
        ReturnPage<BusiChange> returnPage = baseCompanyService.getCompanyChangeHistory(page, companyChangeHistory);
        return ReturnVo.buildSuccess(returnPage);
    }

    @ApiOperation(value = "企业备案列表查询", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/companyBusinessInfoPage", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo companyBusinessInfoPage(@RequestBody RequestPage page, @RequestBody CompanyMapstruct.PageSearchVo searchVo) {
        ReturnPage returnPage = baseCompanyService.companyBusinessInfoPage(page, searchVo);
        return ReturnVo.buildSuccess(returnPage);
    }

    @ApiOperation(value = "企业备案二级列表查询", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/companyBusinessInfoChild", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo companyBusinessInfoChild(@RequestBody CompanyMapstruct.PageSearchVo searchVo) {
        List<BusiInfoMapstruct.BusiInfoVo> busiInfoVoList = baseCompanyService.companyBusinessInfoChild(searchVo);
        return ReturnVo.buildSuccess(busiInfoVoList);
    }

}
